from appium import webdriver

import time

from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

desired_caps = dict()

# 设置中文可输入
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
# 配置 appium
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '111'
# 通话记录页面
# desired_caps['appPackage'] = 'com.android.dialer'
# desired_caps['appActivity'] = '.DialtactsActivity'
# 开发者选项页面
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings$DevelopmentSettingsActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

# 全局等待5s
driver.implicitly_wait(5)
# 1》从一个元素滑动到另一个元素，直到页面自动停止
# 1> 设置好start_button,end_button,执行.scroll方法
# 开发者选项页面 从下往上滑动
start_button = driver.find_element(By.XPATH, "//*[@text='启用WLAN详细日志记录功能']")
end_button = driver.find_element(By.XPATH, "//*[@text='提交错误报告']")
# driver.scroll(start_button, end_button)

# 2》drag_and_drop 拖拽事件
# 从一个元素滑动到另一个元素，第二个元素替代第一个元素原本屏幕上的位置
driver.drag_and_drop(start_button, end_button)



time.sleep(3)

driver.quit()
